package com.monlyu.action.devicesupply;

import com.monlyu.action.BaseAction;
import com.monlyu.bo.DeviceSupplyBo;
import com.monlyu.vo.DeviceSupply;

/**
 * @author SongJun
 * @since 2010-3-7
 * @description
 */
public class EditDeviceSupplyAction extends BaseAction {
	private DeviceSupplyBo deviceSupplyBo;
	private DeviceSupply deviceSupply;
	private Long dsid;
	
	public Long getDsid() {
		return dsid;
	}
	public void setDsid(Long dsid) {
		this.dsid = dsid;
	}
	public DeviceSupply getDeviceSupply() {
		return deviceSupply;
	}
	public void setDeviceSupply(DeviceSupply deviceSupply) {
		this.deviceSupply = deviceSupply;
	}
	public void setDeviceSupplyBo(DeviceSupplyBo deviceSupplyBo) {
		this.deviceSupplyBo = deviceSupplyBo;
	}
	@Override
	public String execute() throws Exception {
		if(null != deviceSupply && null != deviceSupply.getId()){
			deviceSupplyBo.updateSupply(deviceSupply);
		}else{
			deviceSupplyBo.insertDeviceSupply(deviceSupply);
		}
		return ajax("添加更新成功！！！"); 
	}
	
	public String toView(){
		return view("editdevicesupply.jsp");
	}
	public String toEdit(){
		deviceSupply = deviceSupplyBo.getDeviceSupplyById(dsid);
		return view("editdevicesupply.jsp");
	}
	
}
